/*
 * UmbralesElectre3.java
 *
 * Created on 6 de febrero de 2002, 02:16 AM
 */

package InterfacesDiscretas;

/**
 *
 * @author  jfhenao
 */
import javax.swing.*;

public class UmbralesElectre3 extends javax.swing.JDialog {
    
    private static int contador=0;
    private double[][] m_pagos;
    private double[]q;
    private double[]p;
    private double[]v;
    private double[]minimos;
    private double[]maximos;
    private String[]NombreObjetivos;
    private String[]NombresUnidades;
    private InterfacesGenerales.Plataforma Padre2;
    private InterfacesDiscretas.PlataformaDiscreta Padre;
    private int n_objetivos;
    private int n_alternativas;
    
    public UmbralesElectre3(InterfacesDiscretas.PlataformaDiscreta parent,InterfacesGenerales.Plataforma parent2, boolean modal) {
        super(parent2, modal);
        NombreObjetivos=DatosEntrada.DatosDiscretos.getNombresObj();
        NombresUnidades=DatosEntrada.DatosDiscretos.getUnidades();
        n_objetivos=DatosEntrada.DatosDiscretos.getNumeroObj();
        n_alternativas=DatosEntrada.DatosDiscretos.getNumeroAlt();
        m_pagos=DatosEntrada.DatosDiscretos.getMatrizPago();
        maximos= Utiles.SacaMaximosMinimos.MaxiColum(m_pagos,n_alternativas,n_objetivos);
        minimos= Utiles.SacaMaximosMinimos.MiniColum(m_pagos,n_alternativas,n_objetivos);
        initComponents();
        pack();
        java.awt.Dimension nombre=java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setLocation(nombre.width/5,nombre.height/5);
        Padre=parent;
        Padre2=parent2;
        jButton4.setVisible(false);
        if(contador==0)
            jButton1.setVisible(false);
        q=new double[n_objetivos];
        p=new double[n_objetivos];
        v=new double[n_objetivos];
        valoresPredeterminados();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        java.awt.GridBagConstraints gridBagConstraints;

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jSlider1 = new javax.swing.JSlider();
        jSlider2 = new javax.swing.JSlider();
        jSlider3 = new javax.swing.JSlider();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();

        setTitle("ELECTRE III");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });

        jPanel1.setLayout(new java.awt.GridBagLayout());

        jPanel1.setBorder(new javax.swing.border.EtchedBorder());
        jPanel1.setPreferredSize(new java.awt.Dimension(182, 40));
        jLabel1.setFont(new java.awt.Font("Dialog", 1, 14));
        jLabel1.setForeground(new java.awt.Color(102, 102, 0));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("OBJETIVO: "+NombreObjetivos[contador]+"");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 100.0;
        jPanel1.add(jLabel1, gridBagConstraints);

        jLabel2.setForeground(new java.awt.Color(0, 0, 153));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Indiferencia, Preferencia y Veto");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel1.add(jLabel2, gridBagConstraints);

        getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

        jPanel2.setLayout(new java.awt.GridBagLayout());

        jPanel2.setBackground(java.awt.Color.lightGray);
        jPanel2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
        jPanel2.setForeground(new java.awt.Color(0, 0, 153));
        jPanel2.setPreferredSize(new java.awt.Dimension(280, 150));
        jSlider1.setPreferredSize(new java.awt.Dimension(250, 16));
        jSlider1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jSlider1MouseReleased(evt);
            }
        });

        jSlider1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                jSlider1MouseDragged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        jPanel2.add(jSlider1, gridBagConstraints);

        jSlider2.setPreferredSize(new java.awt.Dimension(250, 16));
        jSlider2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jSlider2MouseReleased(evt);
            }
        });

        jSlider2.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                jSlider2MouseDragged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 2;
        jPanel2.add(jSlider2, gridBagConstraints);

        jSlider3.setPreferredSize(new java.awt.Dimension(250, 16));
        jSlider3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jSlider3MouseReleased(evt);
            }
        });

        jSlider3.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                jSlider3MouseDragged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 2;
        jPanel2.add(jSlider3, gridBagConstraints);

        jLabel3.setBackground(java.awt.Color.white);
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Indiferencia");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel2.add(jLabel3, gridBagConstraints);

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("Preferencia");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel2.add(jLabel4, gridBagConstraints);

        jLabel5.setBackground(java.awt.Color.gray);
        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setText("Veto");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel2.add(jLabel5, gridBagConstraints);

        jLabel6.setForeground(new java.awt.Color(0, 0, 153));
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel6.setText("100%");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel2.add(jLabel6, gridBagConstraints);

        jLabel7.setForeground(new java.awt.Color(0, 0, 153));
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel7.setText("0%");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel2.add(jLabel7, gridBagConstraints);

        jLabel8.setForeground(new java.awt.Color(0, 0, 153));
        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel8.setText("0%");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel2.add(jLabel8, gridBagConstraints);

        jLabel9.setForeground(new java.awt.Color(0, 0, 153));
        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel9.setText("100%");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel2.add(jLabel9, gridBagConstraints);

        jLabel10.setForeground(new java.awt.Color(0, 0, 153));
        jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel10.setText("0%");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel2.add(jLabel10, gridBagConstraints);

        jLabel11.setForeground(new java.awt.Color(0, 0, 153));
        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel11.setText("100%");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel2.add(jLabel11, gridBagConstraints);

        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

        jPanel3.setLayout(new java.awt.GridBagLayout());

        jPanel3.setBorder(new javax.swing.border.EtchedBorder());
        jPanel3.setMinimumSize(new java.awt.Dimension(250, 80));
        jPanel3.setPreferredSize(new java.awt.Dimension(250, 80));
        jLabel12.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel12.setForeground(new java.awt.Color(0, 0, 153));
        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel12.setText("Indiferencia:");
        jLabel12.setMaximumSize(new java.awt.Dimension(110, 16));
        jLabel12.setMinimumSize(new java.awt.Dimension(110, 16));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.weightx = 30.0;
        jPanel3.add(jLabel12, gridBagConstraints);

        jLabel13.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel13.setForeground(new java.awt.Color(0, 0, 153));
        jLabel13.setText("Preferencia:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        jPanel3.add(jLabel13, gridBagConstraints);

        jLabel14.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel14.setForeground(new java.awt.Color(0, 0, 153));
        jLabel14.setText("Veto: ");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        jPanel3.add(jLabel14, gridBagConstraints);

        jTextField1.setBackground(java.awt.Color.lightGray);
        jTextField1.setEditable(false);
        jTextField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextField1.setMinimumSize(new java.awt.Dimension(10, 20));
        jTextField1.setPreferredSize(new java.awt.Dimension(20, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 40.0;
        jPanel3.add(jTextField1, gridBagConstraints);

        jTextField2.setBackground(java.awt.Color.lightGray);
        jTextField2.setEditable(false);
        jTextField2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel3.add(jTextField2, gridBagConstraints);

        jTextField3.setBackground(java.awt.Color.lightGray);
        jTextField3.setEditable(false);
        jTextField3.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        jPanel3.add(jTextField3, gridBagConstraints);

        jTextField4.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextField4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField4ActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 30.0;
        jPanel3.add(jTextField4, gridBagConstraints);

        jTextField5.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextField5.setMinimumSize(new java.awt.Dimension(5, 20));
        jTextField5.setPreferredSize(new java.awt.Dimension(5, 20));
        jTextField5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField5ActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 30.0;
        jPanel3.add(jTextField5, gridBagConstraints);

        jTextField6.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jTextField6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField6ActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 30.0;
        jPanel3.add(jTextField6, gridBagConstraints);

        jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel15.setText("   %  (ZMax)   ");
        jLabel15.setMaximumSize(new java.awt.Dimension(500, 16));
        jLabel15.setMinimumSize(new java.awt.Dimension(100, 16));
        jLabel15.setPreferredSize(new java.awt.Dimension(100, 16));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 40.0;
        jPanel3.add(jLabel15, gridBagConstraints);

        jLabel16.setText("Valor en ["+NombresUnidades[contador]+"]");
        jLabel16.setMaximumSize(new java.awt.Dimension(500, 16));
        jLabel16.setMinimumSize(new java.awt.Dimension(100, 16));
        jLabel16.setPreferredSize(new java.awt.Dimension(100, 16));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.weightx = 30.0;
        jPanel3.add(jLabel16, gridBagConstraints);

        getContentPane().add(jPanel3, java.awt.BorderLayout.EAST);

        jPanel4.setLayout(new java.awt.GridBagLayout());

        jPanel4.setPreferredSize(new java.awt.Dimension(277, 45));
        jButton1.setText("< Atr\u00e1s");
        jButton1.setVisible(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        jPanel4.add(jButton1, gridBagConstraints);

        jButton2.setText("Siguiente >");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        jPanel4.add(jButton2, gridBagConstraints);

        jButton3.setText("Ver Gr\u00e1ficas");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        jPanel4.add(jButton3, gridBagConstraints);

        jButton4.setText("Finalizar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        jPanel4.add(jButton4, gridBagConstraints);

        getContentPane().add(jPanel4, java.awt.BorderLayout.SOUTH);

        pack();
    }//GEN-END:initComponents
    
    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed
        try{
            v[contador]=Double.parseDouble(jTextField4.getText());
        }catch(NumberFormatException e){
            jTextField4.setText("");
            jTextField4.grabFocus();
        }
        int vet=(int)(100*(v[contador])/(maximos[contador]));
        jSlider3.setValue(vet);
        jTextField2.setText(""+vet);
        
        if(jSlider3.getValue() <= jSlider2.getValue())
            jSlider3.setValue(jSlider2.getValue());
        if(maximos[contador]<0){
            v[contador]=(-1)*(jSlider3.getValue()*(maximos[contador])/100d);   
        } else {
            v[contador]=(jSlider3.getValue()*(maximos[contador])/100d);
        }
        jTextField2.setText(""+jSlider3.getValue());
        jSlider3.setToolTipText(""+jSlider3.getValue()+"%");
    }//GEN-LAST:event_jTextField4ActionPerformed
    
    private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField6ActionPerformed
        try{
            p[contador]=Double.parseDouble(jTextField6.getText());
        }catch(NumberFormatException e){
            jTextField6.setText("");
            jTextField6.grabFocus();
        }
        int pref=(int)(100*(p[contador]-minimos[contador])/(maximos[contador]-minimos[contador]));
        jSlider2.setValue(pref);
        jTextField3.setText(""+pref);
        
        if(jSlider2.getValue() <= jSlider1.getValue())
            jSlider2.setValue(jSlider1.getValue());
        if(jSlider2.getValue() > jSlider3.getValue())
            jSlider3.setValue(jSlider2.getValue());
        
        if (maximos[contador]<0){
            
            p[contador]=(-1)*(jSlider2.getValue()*(maximos[contador])/100d);
            v[contador]=(-1)*(jSlider3.getValue()*(maximos[contador])/100d);
        } else {
            
            p[contador]=(jSlider2.getValue()*(maximos[contador])/100d);
            v[contador]=(jSlider3.getValue()*(maximos[contador])/100d);
        }
        jTextField3.setText(""+jSlider2.getValue());
        jSlider2.setToolTipText(""+jSlider2.getValue()+"%");
        
        jTextField2.setText(""+jSlider3.getValue());
        jSlider3.setToolTipText(""+jSlider3.getValue()+"%"); 
    }//GEN-LAST:event_jTextField6ActionPerformed
    
    private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField5ActionPerformed
        try{
            q[contador]=Double.parseDouble(jTextField5.getText());
        }catch(NumberFormatException e){
            jTextField5.setText("");
            jTextField5.grabFocus();
        }
        int indf=(int)(100*(q[contador]-minimos[contador])/(maximos[contador]-minimos[contador]));
        jSlider1.setValue(indf);
        jTextField1.setText(""+indf);
        
        if(jSlider1.getValue() > jSlider2.getValue()) {
            jSlider2.setValue(jSlider1.getValue());
            if(jSlider2.getValue() > jSlider3.getValue())
                jSlider3.setValue(jSlider2.getValue());
        }
        
        if(maximos[contador]<0){
            q[contador]=(-1)*(jSlider1.getValue()*(maximos[contador])/100d);
            p[contador]=(-1)*(jSlider2.getValue()*(maximos[contador])/100d);
            v[contador]=(-1)*(jSlider3.getValue()*(maximos[contador])/100d);
        }else{
            q[contador]=(jSlider1.getValue()*(maximos[contador])/100d);
            p[contador]=(jSlider2.getValue()*(maximos[contador])/100d);
            v[contador]=(jSlider3.getValue()*(maximos[contador])/100d);
        }
        
        jTextField1.setText(""+jSlider1.getValue());
        jSlider1.setToolTipText(""+jSlider1.getValue()+"%");
        
        jTextField3.setText(""+jSlider2.getValue());
        jSlider2.setToolTipText(""+jSlider2.getValue()+"%");
        
        jTextField2.setText(""+jSlider3.getValue());
        jSlider3.setToolTipText(""+jSlider3.getValue()+"%");
    }//GEN-LAST:event_jTextField5ActionPerformed
    
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        double q1= Double.parseDouble(jTextField5.getText());
        double p1= Double.parseDouble(jTextField6.getText());
        double v1= Double.parseDouble(jTextField4.getText());
        InterfacesRiesgo.FuncionSatisf pas = new InterfacesRiesgo.FuncionSatisf(Padre2,false,q1,p1,v1, true, NombresUnidades[contador],maximos[contador],NombreObjetivos[contador]);
        pas.show();
        InterfacesRiesgo.FuncionSatisf pas1 = new InterfacesRiesgo.FuncionSatisf(Padre2,false,q1,p1,v1, false, NombresUnidades[contador],maximos[contador],NombreObjetivos[contador]);
        pas1.show();
    }//GEN-LAST:event_jButton3ActionPerformed
    
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        if(contador==1){
            jButton1.setVisible(false);
            jButton4.setVisible(false);
            jButton2.setVisible(true);
        }
        if(contador!=0){
            contador--;
            jTextField5.setText(""+((int)(q[contador]*100))/100d);
            jTextField6.setText(""+((int)(p[contador]*100))/100d);
            jTextField4.setText(""+((int)(v[contador]*100))/100d);
            jLabel1.setText("Ingrese los valores para "+NombreObjetivos[contador]+" de");
            int indfPercent=0;
            int PrefPercent=0;
            int vetoPercent=0;
            
            indfPercent=(int)(100*(q[contador])/(maximos[contador]));
            PrefPercent=(int)(100*(p[contador])/(maximos[contador]));
            vetoPercent=(int)(100*(v[contador])/(maximos[contador]));
            
            jTextField1.setText(""+indfPercent);
            jTextField3.setText(""+PrefPercent);
            jTextField2.setText(""+vetoPercent);
            jSlider1.setValue(indfPercent);
            jSlider2.setValue(PrefPercent);
            jSlider3.setValue(vetoPercent);
            jSlider1.setToolTipText(""+indfPercent+"%");
            jSlider2.setToolTipText(""+PrefPercent+"%");
            jSlider3.setToolTipText(""+vetoPercent+"%");
        }
    }//GEN-LAST:event_jButton1ActionPerformed
    
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        try {
            q[contador]=Double.parseDouble(jTextField5.getText());
        } catch(NumberFormatException e){
            jTextField5.setText("");
            jTextField5.grabFocus();
        }
        try {
            p[contador]=Double.parseDouble(jTextField6.getText());
        } catch(NumberFormatException e){
            jTextField6.setText("");
            jTextField6.grabFocus();
        }
        try{
            v[contador]=Double.parseDouble(jTextField4.getText());
        }catch(NumberFormatException e){
            jTextField4.setText("");
            jTextField4.grabFocus();
        }
        InterfacesDiscretas.LimInfCred pas =new InterfacesDiscretas.LimInfCred(Padre,Padre2,true,q,p,v);
        setVisible(false);
        dispose();
        pas.show();
        contador=0;
    }//GEN-LAST:event_jButton4ActionPerformed
    
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        boolean pasaObjetivo=true;
        try {
            q[contador]=Double.parseDouble(jTextField5.getText());
        } catch(NumberFormatException e) {
            jTextField5.setText("");
            jTextField5.grabFocus();
            pasaObjetivo=false;
        }
        try {
            p[contador]=Double.parseDouble(jTextField6.getText());
        } catch(NumberFormatException e) {
            jTextField6.setText("");
            jTextField6.grabFocus();
            pasaObjetivo=false;
        }
        try {
            v[contador]=Double.parseDouble(jTextField4.getText());
        } catch(NumberFormatException e) {
            jTextField4.setText("");
            jTextField4.grabFocus();
            pasaObjetivo=false;
        }
        pasaObjetivo=revisionDatos();
        
        if(pasaObjetivo==true ){
            if(contador<n_objetivos-1)
                contador++;
            valoresPredeterminados();
            jLabel1.setText("OBJETIVO "+NombreObjetivos[contador]+"");
            jLabel16.setText("Valor en ["+NombresUnidades[contador]+"]");
            if(contador>=n_objetivos-1){
                jButton4.setVisible(true);
                jButton2.setVisible(false);
            }  
        }
        if(contador!=0)
            jButton1.setVisible(true);
    }//GEN-LAST:event_jButton2ActionPerformed
    
    private void jSlider1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jSlider1MouseReleased
        if(jSlider1.getValue() > jSlider2.getValue()) {
            jSlider2.setValue(jSlider1.getValue());
            if(jSlider2.getValue() > jSlider3.getValue())
                jSlider3.setValue(jSlider2.getValue());
        }
        if(maximos[contador]<0){
            q[contador]=(-1)*(jSlider1.getValue()*(maximos[contador])/100d);
            p[contador]=(-1)*(jSlider2.getValue()*(maximos[contador])/100d);
            v[contador]=(-1)*(jSlider3.getValue()*(maximos[contador])/100d);
        } else {
            q[contador]=(jSlider1.getValue()*(maximos[contador])/100d);
            p[contador]=(jSlider2.getValue()*(maximos[contador])/100d);
            v[contador]=(jSlider3.getValue()*(maximos[contador])/100d);
        }
        jTextField1.setText(""+jSlider1.getValue());
        jTextField5.setText(""+((int)(q[contador]*100))/100d);
        jSlider1.setToolTipText(""+jSlider1.getValue()+"%");
        
        jTextField3.setText(""+jSlider2.getValue());
        jTextField6.setText(""+((int)(p[contador]*100))/100d);
        jSlider2.setToolTipText(""+jSlider2.getValue()+"%");
        
        jTextField2.setText(""+jSlider3.getValue());
        jTextField4.setText(""+((int)(v[contador]*100))/100d);
        jSlider3.setToolTipText(""+jSlider3.getValue()+"%");
    }//GEN-LAST:event_jSlider1MouseReleased
    
    private void jSlider2MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jSlider2MouseReleased
        if(jSlider2.getValue() <= jSlider1.getValue())
            jSlider2.setValue(jSlider1.getValue());
        if(jSlider2.getValue() > jSlider3.getValue())
            jSlider3.setValue(jSlider2.getValue());
        if(maximos[contador]<0) {
            p[contador]=(-1)*(jSlider2.getValue()*(maximos[contador])/100d);
            v[contador]=(-1)*(jSlider3.getValue()*(maximos[contador])/100d);
        } else {
            p[contador]=(jSlider2.getValue()*(maximos[contador])/100d);
            v[contador]=(jSlider3.getValue()*(maximos[contador])/100d);
        }
        jTextField3.setText(""+jSlider2.getValue());
        jTextField6.setText(""+((int)(p[contador]*100))/100d);
        jSlider2.setToolTipText(""+jSlider2.getValue()+"%");
        
        jTextField2.setText(""+jSlider3.getValue());
        jTextField4.setText(""+((int)(v[contador]*100))/100d);
        jSlider3.setToolTipText(""+jSlider3.getValue()+"%");
    }//GEN-LAST:event_jSlider2MouseReleased
    
    private void jSlider3MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jSlider3MouseReleased
        if(jSlider3.getValue() <= jSlider2.getValue())
            jSlider3.setValue(jSlider2.getValue());
        
        if(maximos[contador]<0){
            v[contador]=(-1)*(jSlider3.getValue()*(maximos[contador])/100d);
            
        }else{
            v[contador]=(jSlider3.getValue()*(maximos[contador])/100d);
        }
        jTextField2.setText(""+jSlider3.getValue());
        jTextField4.setText(""+((int)(v[contador]*100))/100d);
        jSlider3.setToolTipText(""+jSlider3.getValue()+"%");
    }//GEN-LAST:event_jSlider3MouseReleased
    
    private void jSlider3MouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jSlider3MouseDragged
        if(maximos[contador]<0){
            v[contador]=(-1)*(jSlider3.getValue()*(maximos[contador])/100d);
            
        }else{
            v[contador]=(jSlider3.getValue()*(maximos[contador])/100d);
        }
        jTextField2.setText(""+jSlider3.getValue());
        jTextField4.setText(""+((int)(v[contador]*100))/100d);
        jSlider3.setToolTipText(""+jSlider3.getValue()+"%");
        
    }//GEN-LAST:event_jSlider3MouseDragged
    
    private void jSlider2MouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jSlider2MouseDragged
        if(maximos[contador]<0){
            p[contador]=(-1)*(jSlider2.getValue()*(maximos[contador])/100d);
            
        }else{
            p[contador]=(jSlider2.getValue()*(maximos[contador])/100d);
        }
        jTextField3.setText(""+jSlider2.getValue());
        jTextField6.setText(""+((int)(p[contador]*100))/100d);
        jSlider2.setToolTipText(""+jSlider2.getValue()+"%");
    }//GEN-LAST:event_jSlider2MouseDragged
    
    private void jSlider1MouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jSlider1MouseDragged
        if(maximos[contador]<0){
            q[contador]=(-1)*(jSlider1.getValue()*(maximos[contador])/100d);
        } else {
            q[contador]=(jSlider1.getValue()*(maximos[contador])/100d); 
        }
        jTextField1.setText(""+jSlider1.getValue());
        jTextField5.setText(""+((int)(q[contador]*100))/100d);
        jSlider1.setToolTipText(""+jSlider1.getValue()+"%");
    }//GEN-LAST:event_jSlider1MouseDragged
    
    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        contador=0;
        setVisible(false);
        dispose();
    }//GEN-LAST:event_closeDialog
    
    private void valoresPredeterminados(){
        jSlider1.setValue(10);
        jSlider2.setValue(25);
        jSlider3.setValue(40);
        jTextField1.setText(""+jSlider1.getValue());
        jTextField3.setText(""+jSlider2.getValue());
        jTextField2.setText(""+jSlider3.getValue());
        jSlider1.setToolTipText(""+jSlider1.getValue()+"%");
        jSlider2.setToolTipText(""+jSlider2.getValue()+"%");
        jSlider3.setToolTipText(""+jSlider3.getValue()+"%");
        if(maximos[contador]<0){
            q[contador]=(-1)*((double)jSlider1.getValue()*(maximos[contador])/100d);
        } else{
            q[contador]=((double)jSlider1.getValue()*(maximos[contador])/100d);
        }
        if(maximos[contador]<0){
            p[contador]=(-1)*((double)jSlider2.getValue()*(maximos[contador])/100d);
        } else{
            p[contador]=((double)jSlider2.getValue()*(maximos[contador])/100d);
        }
        if(maximos[contador]<0){
            v[contador]=(-1)*((double)jSlider3.getValue()*(maximos[contador])/100d);  
        } else{
            v[contador]=((double)jSlider3.getValue()*(maximos[contador])/100d);
        }
        jTextField5.setText(""+((int)(q[contador]*100))/100d);
        jTextField6.setText(""+((int)(p[contador]*100))/100d);
        jTextField4.setText(""+((int)(v[contador]*100))/100d);
    }
    
    private boolean revisionDatos() {
        boolean pasa=true;
        if(q[contador]>p[contador] || p[contador]>v[contador]){
            JOptionPane.showMessageDialog(null,"Recuerde \n Indiferencia < Preferencia < Veto","Advertencia",JOptionPane.WARNING_MESSAGE);
            pasa=false;
        }
        
        if(q[contador]<0||p[contador]<0 ||v[contador]<0){
            JOptionPane.showMessageDialog(null,"Los valores a ingresar deben ser positivos","Error",JOptionPane.WARNING_MESSAGE);
            pasa=false;
        }
        return pasa;
    }
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField jTextField6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JSlider jSlider2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JButton jButton3;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JSlider jSlider3;
    private javax.swing.JSlider jSlider1;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton jButton4;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel5;
    // End of variables declaration//GEN-END:variables
}